from chatbot.bot import conf
from chatbot.bot.domain.serializable import Serializable


class TenantInfo(Serializable):
    def __init__(self, tenant_id, name, logo, url, profile):
        self.tenant_id = tenant_id
        self.name = name
        self.logo = logo
        self.url = url
        self.profile = profile


class VisitorInfo(Serializable):
    def __init__(self, name, avatar, visitor_id):
        self.name = name,
        self.avatar = avatar
        self.visitor_id = visitor_id


class Toolbar(Serializable):
    def __init__(self, name, icon, url):
        self.name = name
        self.icon = icon
        self.url = url


class RobotInfo(Serializable):
    def __init__(self, name, avatar):
        self.name = name
        self.avatar = avatar


class QuestionInfo(Serializable):
    def __init__(self, name, qid):
        self.name = name
        self.qid = qid


class Initialization(Serializable):
    __slots__ = (
        'session_id',
        'history_messages',
        'tenant_info',
        'visitor_info',
        'greetings',
        'hot_questions',
        'new_questions',
        'robot_info',
        'language',
        'greeting_recommend_info'
    )

    def __init__(self, **kwargs):
        self.session_id = ''
        self.history_messages = []

        self.visitor_info = VisitorInfo(kwargs.get('user_name', ''), kwargs.get('user_avatar', ''),
                                        kwargs.get('user_id', ''))

        self.tenant_info = TenantInfo(kwargs.get('tenant_id', ''),
                                      kwargs.get('tenant_name', ''),
                                      kwargs.get('tenant_logo', ''),
                                      kwargs.get('tenant_url', ''),
                                      kwargs.get('tenant_profile', '')
                                      )
        self.greetings = []
        self.hot_questions = []
        self.new_questions = []
        self.robot_info = RobotInfo(kwargs.get('robot_name', ''), kwargs.get('robot_avatar', ''))
        self.language = kwargs.get('language', conf.BOT_LANGUAGE_DEFAULT)

        self.greeting_recommend_info = {
            'recommend_script': kwargs.get('recommend_script', ''),
            'questions': []
        }
